//package service.demo;
//
//import mapper.brandMapper;
//import org.apache.ibatis.session.SqlSession;
//import org.apache.ibatis.session.SqlSessionFactory;
//import pojo.Brand;
//import util.factory;
//
//import java.util.List;
//
//public class brandServiceDemo {
//    //获取sql工厂
//    factory f=new factory();
//    SqlSessionFactory sqlSessionFactory=f.getSqlSessionFactory();
//    public List<Brand> selectAll(){
//        //获取sqlSession对象执行sql
//        SqlSession sqlSession = sqlSessionFactory.openSession();
//        //获取类
//        brandMapper mapper = sqlSession.getMapper(brandMapper.class);
//        List<Brand> brands=mapper.selectAll();
//        //释放资源
//        sqlSession.close();
//        return brands;
//    }
//    public void add(Brand brand){
//        SqlSession sqlSession = sqlSessionFactory.openSession();
//        brandMapper mapper = sqlSession.getMapper(brandMapper.class);
//        mapper.add(brand);
//        //注意要提交事物
//        sqlSession.commit();
//        sqlSession.close();
//    }
//    public Brand selectById(int id){
//        SqlSession sqlSession = sqlSessionFactory.openSession();
//        brandMapper mapper = sqlSession.getMapper(brandMapper.class);
//        Brand brand = mapper.selectById(id);
//        //释放资源
//        sqlSession.close();
//        return brand;
//    }
//    public void update(Brand brand){
//        SqlSession sqlSession = sqlSessionFactory.openSession();
//        brandMapper mapper = sqlSession.getMapper(brandMapper.class);
//        mapper.update(brand);
//        //提交事务
//        sqlSession.commit();
//        sqlSession.close();
//    }
//    public void deleteById(int id){
//        SqlSession sqlSession = sqlSessionFactory.openSession();
//        brandMapper mapper = sqlSession.getMapper(brandMapper.class);
//        mapper.deleteById(id);
//        //提交事务
//        sqlSession.commit();
//        //释放资源
//        sqlSession.close();
//    }
//}
